"""
将图片按压缩率压缩

"""
import os
from PIL import Image

# 待压缩图片输入目录
INPUT_DIR = "./raw/"
# 压缩后图片输出目录
OUTPUT_DIR = "./images"
# 压缩率
SCALE = 0.1

input_image_list = os.listdir(INPUT_DIR)
# print(input_image_path_list)

for item in input_image_list:
    img = Image.open(f"{INPUT_DIR}{item}")
    w,h = (int(n*SCALE) for n in img.size)
    img.resize((w, h)).save(f"{OUTPUT_DIR}{item}")